package com.example.demo.fileConfig;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;


@Configuration
public class WebConfig implements WebMvcConfigurer {
    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        // 将 D:/upload/ 下的文件映射到 http://localhost:8080/files/** 访问
        registry.addResourceHandler("/files/**")
                .addResourceLocations("file:D:/upload/");
    }
}
